package com.shk.service.imp;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.shk.dao.PermissionDao;
import com.shk.entity.PageResult;
import com.shk.pojo.Permission;
import com.shk.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = PermissionService.class)
@Transactional
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionDao permissionDao;

    /*权限添加*/
    @Override
    public void add(Permission permission) {
        permissionDao.add(permission);
    }
/*分页查询*/
    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<Permission> page = permissionDao.findPage(queryString);
        return new PageResult(page.getTotal(),page.getResult());

    }

    @Override
    public Permission findById(Integer id) {
        Permission permission = permissionDao.findById(id);
        return permission;
    }

    @Override
    public void update(Permission permission) {
        permissionDao.update(permission);
    }

    @Override
    public void delete(Integer id) {
        permissionDao.delete(id);
    }

    @Override
    public List<Permission> findAll() {

        List<Permission> data = permissionDao.findAll();
        return data;
    }


}
